﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.NetworkInformation;
using System.Threading;
using DeviceSDK.LED;
using DeviceSDK.LED.LingXin;
using DeviceSDK.LED.ShiZhan;
using DeviceSDK.LED.NuoWa;
using DeviceSDK.LED.LiMing;
using BaseHelper.Base;
using DeviceSDK.LED.XianKe;
using System.Drawing;
using BaseHelper.Net;
using DeviceSDK.LED.OnBon;
using DeviceSDK.LED.ZhongHai;


namespace DeviceSDK
{
    public class LEDHelper
    {
        public static string TempFullPath;
        public static int Release_Play_TimeOut = 60;
        public static bool Release_IsOrderToSend = true;
        public static string Release_Local_IP = "";

        public string Error;

        public static string[] GetFirmModelList
        {
            get {
                return new string[] { 
                    "NUOWA_JT100", 
                    "NUOWA_JT100GY",
                    "NUOWA_PSD100", 
                    "LINGXIN_Q3",
                    "LINGXIN_E", 
                    "ONBON_YQ",
                    "ONBON_Y",
                    "ONBON_BX5",
                    "LIMING_MC100", 
                    "SHIZHAN_2010" ,
                    "XIANKE_RXTX",
                    "XIANKE_RXTXGY",
                    "ZHONGHAI_V1"                
                };
            }
        }

        public string Get_Error(string FirmModelIDName,int err)
        {
            if (FirmModelIDName == "ONBON_YQ")
            {
                return OnBon_YQ.Get_Error(err);
            }
            else if (FirmModelIDName == "ONBON_BX5")
            {
                return OnBon_BX5.Get_Error(err);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                return LingXin_Q3.Get_Error(err);
            }
            else if (FirmModelIDName == "LINGXIN_E")
            {
                return LingXin_E.Get_Error(err);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                return ShiZhan_2010.Get_Error(err);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                return NuoWa_PSD100.Get_Error(err);
            }
            else if (FirmModelIDName == "NUOWA_JT100" ||FirmModelIDName == "NUOWA_JT100GY")
            {
                return NuoWa_JT100.Get_Error(err);
            }

            else if (FirmModelIDName == "LIMING_MC100")
            {
                return LiMing_MC100.Get_Error(err);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                return XianKe_RXTX.Get_Error(err);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                return ZhongHai_V1.Get_Error(err);
            }
            else
                return "设备型号不支持！";

        }

        //设备-获取-状态
        public int Get_Status(string FirmModelIDName,string IP)
        {
            //if (FirmModelIDName == "LINGXIN_E")
            //{
            //    return LingXin_E.Test(IP);
            //}
            //else 
              if (FirmModelIDName == "LIMING_MC100")
            {
                return LiMing_MC100.GetStatus(IP) ? 0 : 1; 
            }
            else
                  return PingHelper.Get_Status(IP) ? 0 : 1; ;
        }

        public static void Init()
        {
            //LiMing_MC100.Init();
        }

        public static bool IsCanEmpty(string FirmModelIDName)
        {
            return FirmModelIDName == "NUOWA_JT100GY" || FirmModelIDName == "XIANKE_RXTXGY";
        }

        public static bool IsGetScreen(string FirmModelIDName)
        {
            return FirmModelIDName == "NUOWA_JT100GY" || FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_PSD100";  
        }

        //设备-发送-节目
        public int Send_Program(string FirmModelIDName, string Type,string FilePath, string IP, int Port,int Width=100, int Height=100)
        {
            List<PlaybillProgramInfo> Programs = new List<PlaybillProgramInfo>();
            PlaybillProgramInfo p = new PlaybillProgramInfo();
            p.ID = 0;
            p.Type =  Type;
            p.PlayTime = 5;
            p.X = 0;
            p.Y = 0;
            p.Width = Width;
            p.Height = Height;
            p.IsEffectRand = 0;
            p.FilePath = FilePath;
            Programs.Add(p);

            return Send_Programs(false,FirmModelIDName, IP,Port,Width,Height, Programs.ToArray());
        }

        //设备-发送-节目
        public LEDSendResult Send_ProgramsAndGetResult(string FirmModelIDName, string Type, string FilePath, string IP, int Port, int Width, int Height, int PlayTime)
        {
            List<PlaybillProgramInfo> Programs = new List<PlaybillProgramInfo>();
            PlaybillProgramInfo p = new PlaybillProgramInfo();
            p.ID = 0;
            p.Type = Type;
            p.PlayTime = PlayTime;
            p.X = 0;
            p.Y = 0;
            p.Width = Width;
            p.Height = Height;
            p.IsEffectRand = 0;
            p.FilePath = FilePath;
            Programs.Add(p);

            return Send_ProgramsAndGetResult(false, FirmModelIDName, IP, Port, Width, Height, Programs.ToArray());
        }

        //发送单个节目
        public int Send_Program(bool IsTempPlaybill, string FirmModelIDName, string IP,int Port, int Width,int Height,PlaybillProgramInfo Program)
        {
            List<PlaybillProgramInfo> Programs = new List<PlaybillProgramInfo>();
            Programs.Add(Program);
            return Send_Programs(IsTempPlaybill, FirmModelIDName, IP,Port,Width,Height, Programs.ToArray());
        }

        //设备-发送-节目
        public int Send_Programs(bool IsTempPlaybill,string FirmModelIDName, string IP,int Port,int Width,int Height, PlaybillProgramInfo[] Programs,string PlaybillID="")
        {
            LEDSendResult result = Send_ProgramsAndGetResult(IsTempPlaybill, FirmModelIDName, IP, Port, Width, Height, Programs, PlaybillID);
            return result.RetCode;
        }

        //设备-发送-节目
        public LEDSendResult Send_ProgramsAndGetResult(bool IsTempPlaybill, string FirmModelIDName, string IP, int Port, int Width, int Height, PlaybillProgramInfo[] Programs, string PlaybillID = "")
        {
            LEDSendResult result = new LEDSendResult(false);
            int ret = 0;
            
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Send_Programs(IP, Programs);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Send_Programs(IP, Width, Height, OnBon_ProductID.BX_Y2L, Programs);
                Error = OnBon_Y.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_BX5")
            {
                ret = OnBon_BX5.Send_Programs(IP, Width, Height, Programs);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                ret = LingXin_Q3.Send_Programs(IP, Programs);
                Error = LingXin_Q3.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_E")
            {
                ret = LingXin_E.Send_Programs(IP, Width, Height, Programs);
                Error = LingXin_E.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Send_Programs(IP, Programs);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Send_Programs(IsTempPlaybill, IP, Width, Height, Programs);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100")
            {
                result = NuoWa_JT100.Send_Programs(IsTempPlaybill, IP, Port, Width, Height, Programs, PlaybillID,true);
                Error = NuoWa_JT100.Get_Error(result.RetCode);
            }
            else if (FirmModelIDName == "NUOWA_JT100GY")
            {
                result = NuoWa_JT100GY.Send_Programs(IsTempPlaybill, IP, Width, Height, Programs,true);
                Error = NuoWa_JT100GY.Get_Error(result.RetCode);
            }
            else if (FirmModelIDName == "LIMING_MC100")
            {
                ret = LiMing_MC100.Send_Programs(IP, Width, Height, Programs);
                Error = LiMing_MC100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX")
            {
                result = XianKe_RXTX.Send_Programs(IsTempPlaybill, IP, Port, Width, Height, Programs,true);
                Error = XianKe_RXTX.Get_Error(result.RetCode);
            }
            else if (FirmModelIDName == "XIANKE_RXTXGY")
            {
                result = XianKe_RXTXGY.Send_Programs(IsTempPlaybill, IP, Port, Width, Height, Programs,true);
                Error = XianKe_RXTX.Get_Error(result.RetCode);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                result = ZhongHai_V1.Send_Programs(IP, Port, Width, Height, Programs,true);
                Error = ZhongHai_V1.Get_Error(result.RetCode);
            }
            else
            {

                result.RetCode = 1;
                Error = "设备型号不支持！";
            }

            return result;
        }
        public int Get_File(string FirmModelIDName, string IP, int Port, string RemotePath,ref byte[] FileBody)
        {
            int ret = -1;

            if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Get_File(IP, Port, RemotePath,ref FileBody);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            //else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            //{
            //    ret=NuoWa_JT100.Get_Brightness
            //}
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        public int Send_File(string FirmModelIDName, string IP, int Port,string RemotePath,string FilePath)
        {
            int ret = -1;

            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Send_File(IP, Port, RemotePath, FilePath);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Send_File(IP, Port,RemotePath,FilePath);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        //获取播放节目单名称
        public int Get_PlaybillContent(string FirmModelIDName, string IP,int Port,ref string Content)
        {
            int ret = -1;

            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Get_PlaybillContent(IP, Port, ref Content);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Get_PlaybillContent(IP, Port, ref Content);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                ret = ZhongHai_V1.Get_PlaybillContent(IP, Port, ref Content);
                Error = ZhongHai_V1.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        //获取播放节目单名称
        public int Set_PlaybillID(string FirmModelIDName, string IP, int Port, string ID)
        {
            int ret = -1;

            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_PlaybillID(IP, Port, ID);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Set_PlaybillID(IP, Port, ID);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        public int Set_VirtualCheck_Open(string FirmModelIDName, string IP, int Port, string DefaultPlaybillID,int TimeOut=30)
        {
            int ret = -1;
            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_VirtualCheck(IP,Port, true, DefaultPlaybillID, TimeOut);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        public int Set_VirtualCheck_Close(string FirmModelIDName, string IP, int Port)
        {
            int ret = -1;
            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_VirtualCheck(IP, Port, false);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        //设备-获取屏幕截图
        public int Get_ScreenCap(string FirmModelIDName, string IP,int Port,int Width,int Height,ref Image Img)
        {
            int ret = -1;

            if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Get_ScreenCap(IP,ref Img);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Get_ScreenCap(IP, Port, ref Img);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Get_ScreenCap(IP,Width,Height,ref Img);
                Error = OnBon_Y.Get_Error(ret);
            }
            else
            {
                ret = 1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        //设备-LED点检
        public int Get_LedCheckErrorCount(string FirmModelIDName, string IP,int Port)
        {
            int ret = -1;

            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Get_LedCheckErrorCount(IP, Port);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        
        }

        //设备-LED点检
        public int Get_LedCheckResult(string FirmModelIDName, string IP,int Port,ref string Result)
        {
            int ret = -1;

            if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Get_LedCheckResult(IP, Port, ref Result);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;

        }

        //设备-重启
        public int Set_Reboot(string FirmModelIDName, string IP,int Port=0)
        {
            int ret = -1;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Set_Reboot(IP);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                ret = LingXin_Q3.Set_Reboot(IP);
                Error = LingXin_Q3.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Set_Reboot(IP);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_Reboot(IP, Port);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "LIMING_MC100")
            {
                ret = LiMing_MC100.Set_Reboot(IP);
                Error = LiMing_MC100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Set_Reboot(IP,Port);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else
            {
                ret = 1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        //设备-获取开关屏
        public int Get_Screen_Status(string FirmModelIDName,string IP,int Port,ref int Value)
        {
            int ret = -1;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Get_Screen_Status(IP, ref  Value);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Get_Screen_Status(IP, ref Value);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Get_Screen_Status(IP, ref Value);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Get_Screen_Status(IP, Port, ref Value);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                ret = ZhongHai_V1.Get_Screen_Status(IP, Port, ref Value);
                Error = ZhongHai_V1.Get_Error(ret);
            }
            else
            {
                ret = 1;
                Value = -1;
                Error = "设备型号不支持！";
            }

            return ret;
        }

        //设备-屏幕-开屏
        public int Set_Screen_Open(string FirmModelIDName, string IP,int Port)
        {
            int ret = 0;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Set_Screen_Open(IP);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Set_Screen_Open(IP);
                Error = OnBon_Y.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                ret = LingXin_Q3.Set_Screen_Open(IP);
                Error = LingXin_Q3.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_E")
            {
                ret = LingXin_E.Set_Screen_Open(IP);
                Error = LingXin_E.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Set_Screen_Open(IP);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Set_Screen_Open(IP);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_Screen_Open(IP, Port);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Set_Screen_Open(IP,Port);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                ret = ZhongHai_V1.Set_Screen_Open(IP, Port);
                Error = ZhongHai_V1.Get_Error(ret);
            }
            else
            { 
                ret = 1;
                Error = "设备型号不支持！";
            }


            return ret;
        }

        //设备-屏幕-关屏
        public int Set_Screen_Close(string FirmModelIDName, string IP, int Port)
        {
            int ret = 0;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Set_Screen_Close(IP);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Set_Screen_Close(IP);
                Error = OnBon_Y.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                ret = LingXin_Q3.Set_Screen_Close(IP);
                Error = LingXin_Q3.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_E")
            {
                ret = LingXin_E.Set_Screen_Close(IP);
                Error = LingXin_E.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Set_Screen_Close(IP);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Set_Screen_Close(IP);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_Screen_Close(IP, Port);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Set_Screen_Close(IP,Port);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                ret = ZhongHai_V1.Set_Screen_Close(IP, Port);
                Error = ZhongHai_V1.Get_Error(ret);
            }
            else
            {
                ret = 1;
                Error = "设备型号不支持！";
            }


            return ret;
        }

        //设备-亮度
        public int Get_Brightness(string FirmModelIDName, string IP,int Port,ref int Value)
        {
            int ret = 0;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Get_Brightness(IP,ref Value);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Get_Brightness(IP, ref Value);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Get_Brightness(IP, ref Value);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Get_Brightness(IP, Port, ref Value);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Get_Brightness(IP,Port,ref Value);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                ret = ZhongHai_V1.Get_Brightness(IP, Port,ref Value);
                Error = ZhongHai_V1.Get_Error(ret);
            }
            else 
            {
                ret = -1;
                Value = -1;
                Error = "设备型号不支持！";
            }

            return ret;
        }

        //设备-亮度
        public int Set_Brightness(string FirmModelIDName, string IP,int Port,int Value)
        {
            int ret = 0;

            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Set_Brightness(IP, Value);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Set_Brightness(IP, Value);
                Error = OnBon_Y.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                ret = LingXin_Q3.Set_Brightness(IP,Value);
                Error = LingXin_Q3.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_E")
            {
                ret = LingXin_E.Set_Brightness(IP, Value);
                Error = LingXin_E.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Set_Brightness(IP, Value);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Set_Brightness(IP, Value);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_Brightness(IP, Port, Value);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Set_Brightness(IP, Port, Value);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else if (FirmModelIDName == "ZHONGHAI_V1")
            {
                ret = ZhongHai_V1.Set_Brightness(IP, Port,Value);
                Error = ZhongHai_V1.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }
            return ret;
        }

        //设备-音量
        public int Get_Volume(string FirmModelIDName, string IP,int Port, ref int Value)
        {
            int ret = 0;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Get_Volume(IP, ref Value);
                Error = OnBon_YQ.Get_Error(ret);
            }

            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Get_Volume(IP, ref Value);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Value = -1;
                Error = "设备型号不支持！";
            }

            return ret;
        }

        //设备-音量
        public int Set_Volume(string FirmModelIDName, string IP, int Port,int Value)
        {
            int ret = 0;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Set_Volume(IP, Value);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Set_Volume(IP,Value);
                Error = OnBon_Y.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Set_Volume(IP, Value);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Value = -1;
                Error = "设备型号不支持！";
            }

            return ret;
        }

        //设备-时间
        public int Set_Time(string FirmModelIDName, string IP,int Port=0)
        {
            int ret = 0;
            if (FirmModelIDName == "ONBON_YQ")
            {
                OnBon_YQ onbon = new OnBon_YQ();
                ret = onbon.Set_Time(IP);
                Error = OnBon_YQ.Get_Error(ret);
            }
            else if (FirmModelIDName == "ONBON_Y")
            {
                ret = OnBon_Y.Set_Time(IP);
                Error = OnBon_Y.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_Q3")
            {
                ret = LingXin_Q3.Set_Time(IP);
                Error = LingXin_Q3.Get_Error(ret);
            }
            else if (FirmModelIDName == "LINGXIN_E")
            {
                ret = LingXin_E.Set_Time(IP);
                Error = LingXin_E.Get_Error(ret);
            }
            else if (FirmModelIDName == "SHIZHAN_2010")
            {
                ret = ShiZhan_2010.Set_Time(IP);
                Error = ShiZhan_2010.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_PSD100")
            {
                ret = NuoWa_PSD100.Set_Time(IP);
                Error = NuoWa_PSD100.Get_Error(ret);
            }
            else if (FirmModelIDName == "NUOWA_JT100" || FirmModelIDName == "NUOWA_JT100GY")
            {
                ret = NuoWa_JT100.Set_Time(IP, Port);
                Error = NuoWa_JT100.Get_Error(ret);
            }
            else if (FirmModelIDName == "LIMING_MC100")
            {
                ret = LiMing_MC100.Set_Time(IP);
                Error = LiMing_MC100.Get_Error(ret);
            }
            else if (FirmModelIDName == "XIANKE_RXTX" || FirmModelIDName == "XIANKE_RXTXGY")
            {
                ret = XianKe_RXTX.Set_Time(IP,Port);
                Error = XianKe_RXTX.Get_Error(ret);
            }
            else
            {
                ret = -1;
                Error = "设备型号不支持！";
            }

            return ret;
        }


    }
}
